package com.ma.disk.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")

public class UserController {

//    @Autowired
//    UserMapper userMapper;


    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public String login(HttpSession httpSession, @RequestParam("userName") String userName, @RequestParam("userPassword")String userPassword, Model model){
//        System.out.println("name:"+userName + " " + "password:" + " " + userPassword);
//        String info = "";
//        User user = userMapper.getLoginUser(userName);
//        if (user.getAdminName() != null){
//            info = "OK";
//        }else {
//            info = "无此用户！！";
//        }
//        if (user.getAdminPassword().equals(userPassword)){
//            httpSession.setAttribute("user",user);
//            model.addAttribute("msg","登陆成功");
//            info = "密码输入正确";
//            return "redirect:testObs";
//        }else {
//            model.addAttribute("msg","error");
//            return "index";
//        }
        return null;
    }

    @RequestMapping("/logout")
    public String loginOut(HttpSession session,Model model){
        session.invalidate();
        return "redirect:index";
    }

}
